package com.itany.corejava.day16;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;

public class TestClientB {

    public static void main(String[] args) {

        System.out.println("客户端");

        Scanner sc=new Scanner(System.in);

        try(Socket s=new Socket("127.0.0.1",8888);
            PrintWriter pw=new PrintWriter(
                    s.getOutputStream()
            );
            BufferedReader br=new BufferedReader(
                    new InputStreamReader(
                            s.getInputStream()
                    )
            )){


            System.out.println("name:");
            String name=sc.nextLine();


            pw.println(name);

            pw.flush();

            String message=br.readLine();

            System.out.println(message);

        }catch (Exception e){
            e.printStackTrace();
        }


    }

}
